﻿@model IEnumerable<ItemTemplate>
@{
    ViewBag.Title = "Site templates".Localize();
    //Layout = "~/Areas/Sites/Views/Shared/Global.cshtml";
    Layout = "~/Views/Shared/Site.cshtml";

}
@*@section SideBar_Top{
    @Html.Partial("_SidebarTopSearch")
}*@
@section Panel{

    <ul class="panel">
        <li>
            <a href="@Url.Action("Upload", ViewContext.RequestContext.AllRouteValues().Merge("return", ViewContext.HttpContext.Request.RawUrl))">
                @Html.IconImage("upload") @("Upload".Localize())</a>
        </li>
        <li><a href="@Url.Action("Delete", ViewContext.RequestContext.AllRouteValues().Merge("return", ViewContext.HttpContext.Request.RawUrl))" data-show-on-check="Any" data-command-type="AjaxPost" data-confirm="@("Are you sure you want to delete these items?".Localize())">
            @Html.IconImage("delete") @("Delete".Localize())</a></li>
        @foreach (var group in Kooboo.CMS.Sites.Extension.UI.TopToolbar.ToolbarButtons.GetToolbarButtons(ViewContext.RequestContext))
        {
            @Html.Partial("_ToolbarGroupButtons", group)
        }
    </ul>
}

<div class="topbar">
    <h1 class="title">@ViewBag.Title <a href="http://sites.kooboo.com" target="_blank" class="title-tip">@("Browse more templates online".Localize())</a></h1>
</div>
<div class="block fixed">
    <ul class="site-list">
        @foreach (var item in Model)
        {
            <li>
                <span>
                    <input type="checkbox" name="select" class="select" value="@item.UUID" id="@item.UUID"  data-id-property="UUID" autocomplete="off"/>
                    <label for="@item.TemplateName"></label>
                    <span class="corner"></span>
                    <img src="@Url.Content(string.IsNullOrEmpty(item.Thumbnail) ? "~/Images/Default.png" : item.Thumbnail)" />
                </span>
                <label class="name" for="@item.TemplateName">@item.TemplateName</label>
            </li>
        }
    </ul>
</div>
<script>
    $(function () {
        var $siteList = $('.site-list');
        var $check_relateds = $('[data-show-on-check]');
        var selector = 'input:checkbox.select:checked';
        function reset() {
            $siteList.reset_check_relateds({ check_relateds: $check_relateds, selector: selector });
        }
        reset();
        $siteList.find('input:checkbox.select').change(function () {
            reset();
        });
        $siteList.grid();
    });
</script>
